home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / telecom / 96 / c / cc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-01-15  |  3.4 KB  |  132 lines

  1. /* FILE:         cc.c
  2.  * DATE:         30-Dec-1986
  3.  * AUTHOR:       Robert Royar rdroya01@bitnet
  4.  * SYSTEM:       Atari ST
  5.  * COMPILER:     Alcyon v. 4.14
  6.  * PURPOSE:      A simple minded compiler driver, no frills.
  7.  * USAGE:        cc filename (no .C extension or path for the filename)
  8.  * DISTRIBUTION: Public Domain.  Do with it what you will.  Just leave
  9.  *               the header intact.
  10.  */
  11. #include <stdio.h>
  12. #include <osbind.h>
  13. #include <ctype.h>
  14. #include <errno.h>
  15.  
  16. unsigned long _STKSIZ = 16284;    /* keep 16K */
  17. static char sdir[81] = "E:\\";    /* where the source files are */
  18. static char include[81] = "D:\\STDLIB.H\\"; /* include files */
  19. static char tdir[81] = "M:\\";    /* temporary files (all of them) */
  20. static char bin[81] = "C:\\BIN\\";    /* compiler directory */
  21. static char symb[81] = "C:\\BIN\\";    /* as68 symbols */
  22. static char tdrvnm[80] = "M";        /* log into this drive */
  23. int temdrv;
  24. static char path[128];
  25. int exec;
  26. int curdrv;
  27. char author[30] = "Robert Royar";
  28.  
  29. main(argc,argv)
  30. register int argc;
  31. char *argv[];
  32. {
  33.     static char pname[81];
  34.     static char command[81];
  35.  
  36.     if (argc != 2)
  37.         {
  38.         fprintf(stderr,"usage: %s filename",argv[0]);
  39.         exit(-1);
  40.         }
  41.     curdrv = (int)Dgetdrv(); /* 0 = A */
  42.     Dgetpath(path,(1+curdrv)); /* 1 = A */
  43.     if (access("cc.ini",4) != -1)
  44.         if (!inivar())
  45.             exit(-1);
  46.     sprintf(command,"%s%s.c",sdir,argv[1]);
  47.     temdrv = (int)(tdrvnm[0] - 'A');
  48.     Dsetdrv(temdrv);    /* Log into temp drive */
  49.     if((exec=(int)Dsetpath(tdir))!=0)
  50.         exit(exec);
  51.     if (access(command,4) == -1)
  52.         exit(EACCES);
  53.     sprintf(&command[1],"-i %s %s%s.c %s%s.i ",
  54.         include,sdir,argv[1],tdir,argv[1]);
  55.     command[0] = (char)strlen(&command[1]);
  56.     sprintf(pname,"%sCP68.PRG",bin);
  57.     if((exec=(int)Pexec(0,pname,command,0L))!=0)
  58.         exit(exec);
  59.     sprintf(&command[1],"%s%s.i %s%s.1 %s%s.2 %s%s.3",
  60.         tdir,argv[1],tdir,argv[1],tdir,argv[1],tdir,argv[1]);
  61.     command[0] = (char)strlen(&command[1]);
  62.     sprintf(pname,"%sC068.PRG",bin);
  63.     if((exec=(int)Pexec(0,pname,command,0L))!=0)
  64.         exit(exec);
  65.     sprintf(command,"%s%s.i",tdir,argv[1]);
  66.     unlink(command);
  67.     sprintf(&command[1],"%s%s.1 %s%s.2 %s%s.s",
  68.     tdir,argv[1],tdir,argv[1],tdir,argv[1]);
  69.     command[0] = (char)strlen(&command[1]);
  70.     sprintf(pname,"%sC168.PRG",bin);
  71.     if((exec=(int)Pexec(0,pname,command,0L))!=0)
  72.         exit(exec);
  73.     sprintf(command,"%s%s.1",tdir,argv[1]);
  74.     unlink(command);
  75.     sprintf(command,"%s%s.2",tdir,argv[1]);
  76.     unlink(command);
  77.     sprintf(&command[1],"-l -u -s %s %s%s.s",bin,tdir,argv[1]);
  78.     command[0] = (char)strlen(&command[1]);
  79.     sprintf(pname,"%sAS68.PRG",bin);
  80.     if((exec=(int)Pexec(0,pname,command,0L))!=0)
  81.         exit(exec);
  82.     sprintf(command,"%s.s",tdir,argv[1]);
  83.     unlink(command);
  84.     Dsetdrv(curdrv);
  85.     Dsetpath(path);
  86.     exit(0);
  87. }
  88.  
  89. inivar()
  90. {
  91.     FILE *freopen();
  92.     char *gets();
  93.     int ln = 0;
  94.     static char line[81];
  95.  
  96.     if (freopen("cc.ini","r",stdin) != stdin)
  97.         {
  98.         fprintf(stderr,"cc: cannot open %scc.ini\n",path);
  99.         return(0);
  100.         }
  101.     while (gets(line))
  102.         {
  103.         switch(ln)
  104.             {
  105.             case 0:
  106.                 strncpy(sdir,line,80);
  107.                 break;
  108.             case 1:
  109.                 strncpy(include,line,80);
  110.                 break;
  111.             case 2:
  112.                 strncpy(tdir,line,80);
  113.                 break;
  114.             case 3:
  115.                 strncpy(bin,line,80);
  116.                 break;
  117.             case 4:
  118.                 strncpy(symb,line,80);
  119.                 break;
  120.             case 5:
  121.                 strncpy(tdrvnm,line,80);
  122.                 break;
  123.             default:
  124.                 break;
  125.             }
  126.         ++ln;
  127.         if (feof(stdin))
  128.             break;
  129.         }
  130.     return(1);
  131. }
  132.